package se.gu.sem;


import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.webkit.WebView;

public class RegisterActivity extends Activity implements OnClickListener{
	
	WebView mWebView;
	  @Override
	    public void onCreate(Bundle savedInstanceState) {
	        super.onCreate(savedInstanceState);
	        
	        
	          GUApp univ = ((GUApp)getApplicationContext());
	          
	          if(univ.getUniv().equals("GU"))
	        	  setContentView(R.layout.guregisterforexam);
	          else if(univ.getUniv().equals("CH"))
	        	  setContentView(R.layout.chregisterforexam);
	        
	        
	        
	        
		    mWebView = (WebView) findViewById(R.id.webview);
		    mWebView.getSettings().setJavaScriptEnabled(true);
		    
	        if(univ.getUniv().equals("GU"))
	        	 mWebView.loadUrl("http://lpw.it.gu.se/uPortal/render.userLayoutRootNode.uP");
	        else if(univ.getUniv().equals("CH"))
	        	 mWebView.loadUrl("https://student.portal.chalmers.se/en/Studies/Examinations/Pages/Examination%20sign-up.aspx");
	        
		   
		    mWebView.setWebViewClient(new PageHandler());
	    }

	   @Override
	    public boolean onCreateOptionsMenu(Menu menu) {
	        MenuInflater inflater = getMenuInflater();
	        inflater.inflate(R.menu.menureg, menu);
	        return true;
	    }
	    
	    @Override
	    public boolean onOptionsItemSelected(MenuItem item)
	    {    	
	    if(item.getTitle().toString().equals("Home"))
	    {	
	    	System.out.println();
	    	   Intent intent = new Intent(RegisterActivity.this,GUActivity.class);
	    	   startActivity(intent);    
	    	   return true;
	     }
	    if(item.getTitle().toString().equals("Program Info"))
	    {    
	    	System.out.println();
	   	   Intent intent = new Intent(RegisterActivity.this,ProgrameInfoActivity.class);
	   	   startActivity(intent);    
	   	   return true;
	    }
	      if(item.getTitle().toString().equals("Practical Info"))
	      {
	      	System.out.println();
	      	Intent intent = new Intent(RegisterActivity.this,PracticalInfo.class);
	      	startActivity(intent);    
	      	return true;   
	      }
	       
	      if(item.getTitle().toString().equals("Twitter"))
	      {    
	    	  
	    	  
	    	  
	    	  GUApp univ = ((GUApp)getApplicationContext());
			  univ.setView("twitter");
	    	  
	     	  Intent intent = new Intent(RegisterActivity.this,LoadingScreen.class);
	     	  startActivity(intent);    
	     	  return true;
	      }
	      
	      if(item.getTitle().toString().equals("About"))
	      {    

	     	   Intent intent = new Intent(RegisterActivity.this,AboutActivity.class);
	     	   startActivity(intent);    
	     	   return true;
	      }
	      
	     return super.onOptionsItemSelected(item);
	    
	    }
	      
	       
	      
	    
	    @Override
	    public void onClick(View v) {
	    	
	    	
	    	
	      	Intent intent = new Intent(RegisterActivity.this,PageViewer.class);
	      	startActivity(intent);     
	    	
	        }
}